package com.it.flashsale;

import com.it.Task.MyTask;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@SpringBootApplication
public class FlashSaleApplication {

    public static void main(String[] args) {
        SpringApplication.run(FlashSaleApplication.class, args);
        //创建线程池对象  Ctrl P 提醒
        //核心线程数量，最大线程数量，等待时间,任务队列缓存多少个
        ThreadPoolExecutor pool = new ThreadPoolExecutor(3,5,1, TimeUnit.MINUTES, new LinkedBlockingQueue<>(15));
        //循环创建任务对象
        for (int i = 0; i <20 ; i++) {
            MyTask mytask = new MyTask("客户"+i);
            pool.submit(mytask);
        }
        //关闭线程池
        pool.shutdown();


    }

}
